﻿using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Unity;
using Astor.Modules.DataSources.Models;
using System.Collections.ObjectModel;
using Astor.Modules.DataSources.Services;
using Moq;

namespace Astor.Modules.DataSources.Tests
{
    public class MockContainer : UnityContainer
    {
        public MockContainer() : base()
        {
            ObservableCollection<DataSource> dataSources = new ObservableCollection<DataSource>()
            {
                new DataSource { Id = Guid.NewGuid(), Name = "Name1", Url="Url1" },
                new DataSource { Id = Guid.NewGuid(), Name = "Name2", Url="Url2" }
            };
            var _mockDataSourceService = new Mock<IDataSourcesService>();
            _mockDataSourceService.Setup(m => m.FindAll()).Returns(dataSources);
            _mockDataSourceService.Setup(m => m.Exists(It.IsAny<string>()))
                .Returns((string s) => dataSources.Where(ds => ds.Name == s).Count() > 0);

            this.RegisterInstance<Mock<IDataSourcesService>>(_mockDataSourceService);
            this.RegisterInstance<IDataSourcesService>(_mockDataSourceService.Object);
        }

        
    }
}
